/*
    * Copyright (c) 2024 Hunan OpenValley Digital Industry Development Co., Ltd.
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    *     http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
 */

#ifndef FILE_SHARE_COMMON_H
#define FILE_SHARE_COMMON_H

#include <cstdint>
#include <string>

namespace OHOS {
namespace FileShare {
#define BUNDLE_NAME_KEY "bundleName"
#define DEVICE_ID_KEY "deviceId"
#define NETWORK_ID_KEY "networkId"
#define DEVICE_NAME_KEY "deviceName"
#define FILES_KEY "files"
#define FOLDER_NAME_KEY "folderName"

#define SIZE_KEY "size"
#define PATH_KEY "path"
#define HASH_KEY "hash"
#define NAME_KEY "name"
#define UTD_KEY "utd"
#define URI_KEY "uri"
#define ORIG_FILE_NAME_KEY "origFileName"
#define NEW_FILE_NAME_KEY "newFileName"
#define RECV_PATH "recvPath"

#define PROGRESS_KEY "progress"
#define SHARE_TYPE_KEY "shareType"
#define SPEED_KEY "speed"

#define FILE_SHARE_UUID 0xFE35
#define ORIGIN_UUID 0xFDEE

#define FS_NAPI_BUF_LENGTH (256)

enum class SendType : int32_t {
    SRC = 0,
    SINK = 1,
};

enum class SendState : int32_t {
    UNKNOWN = 0,
    PROCESSING = 1,
    SUCCESS = 2,
    FAILURE = 3,
    CANCEL = 4,
    ABORT = 5,
};

enum class ShareType : int32_t {
    UNKNOWN = -1,
    SAVE_TO_MEDIA_ASSET = 1,
    SAVE_AS_FILE = 2,
    SAVE_AS_FOLDER = 10,
};

struct FSNapiFileInfo {
    int size = 0;
    char uri[FS_NAPI_BUF_LENGTH] = "";
    char name[FS_NAPI_BUF_LENGTH] = "";
    char utd[FS_NAPI_BUF_LENGTH] = "";
};

struct FileInfo {
    int size = 0;
    std::string path = "";
    std::string name = "";
    std::string hash = "";
    std::string utd = "";
    std::string uri = "";
    std::string origFileName = "";
    std::string newFileName = "";
    std::string recvPath = "";
};

struct SendInfo {
    int progress = 0; // range 0~100
    ShareType type = ShareType::UNKNOWN;
    int speed = 0;
    std::vector<FileInfo> files {};
};

struct SendTask {
    std::vector<FileInfo> files {};
    std::string deviceName = "";
    std::string deviceId = "";
    std::string networkId = "";
    ShareType type = ShareType::UNKNOWN;
    std::string folderName = "";
};

int32_t InitCommonEventMonitor(void);

} // namespace FileShare
} // namespace OHOS
#endif // FILE_SHARE_COMMON_H